//
//  TextTableViewCell.m
//  GoldBook
//
//  Created by wmz on 2021/8/19.
//  Copyright © 2021 wmz. All rights reserved.
//

#import "TextTableViewCell.h"

@implementation TextTableViewCell

- (void)setGNModel:(BaseCellModel*)data{
    self.model = data;
    data.notCacheHeight = YES;
    self.heightLayout.constant = (data.titleWidth == 80)?20:data.titleWidth;
    self.lineView.hidden = !data.lineHidden;
    self.nameLB.numberOfLines = data.numOfLines;
    if ([data.title isKindOfClass:NSString.class]) {
        self.nameLB.add_text(GNFillEmptySpace(data.title))
        .add_font(data.titleFont)
        .add_textColor(data.titleColor);
    }else if ([data.title isKindOfClass:NSAttributedString.class]) {
        self.nameLB.attributedText = (NSAttributedString*)data.title;
    }
    self.nameLB.backgroundColor = data.titleBackColor;
    self.nameLB.textAlignment = data.rightHigh?NSTextAlignmentCenter:NSTextAlignmentLeft;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.nameLB.hd_edgeInsets = self.model.insets;
    [self setNeedsUpdateConstraints];
}

@end
